package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.ModuleSeriesDao;
import com.sugon.entity.ModuleSeriesEntity;
import com.sugon.service.ModuleSeriesService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

import static com.sugon.utils.ShiroUtils.getUserId;

/**
 * 模具机型Service实现类
 *
 * @author sugon
 * @date 2019-08-19 11:47:01
 */
@Service("moduleSeriesService")
public class ModuleSeriesServiceImpl implements ModuleSeriesService {
    @Autowired
    private ModuleSeriesDao moduleSeriesDao;

    @Override
    public ModuleSeriesEntity queryObject(String id) {
        return moduleSeriesDao.queryObject(id);
    }

    @Override
    public List<ModuleSeriesEntity> queryList(Map<String, Object> map) {
        return moduleSeriesDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return moduleSeriesDao.queryTotal(map);
    }

    @Override
    public int save(ModuleSeriesEntity moduleSeries) {
        moduleSeries.setId(RandomUtil.randomString(32));
        moduleSeries.setCreater(getUserId());
        moduleSeries.setCreateTime(new Date());
        moduleSeries.setDelFlag(1);
        return moduleSeriesDao.save(moduleSeries);
    }

    @Override
    public int update(ModuleSeriesEntity moduleSeries) {
        moduleSeries.setUpdateTime(new Date());
        moduleSeries.setUpdateUser(getUserId());
        return moduleSeriesDao.update(moduleSeries);
    }

    @Override
    public int delete(String id) {
        return moduleSeriesDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return moduleSeriesDao.deleteBatch(ids);
    }
}
